/*年轻人，只管向前看，不要管自暴自弃者的话*/
package com.composetest.page.product.detail.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavType
import androidx.navigation.navArgument
import com.composetest.page.product.detail.ProductDetailRoute
import com.composetest.ui.navigation.myComposable

/**
 * create by itz on 2024-10-16 16:33
 * desc :
 **/

const val PRODUCT_ID = "product_id"
const val PRODUCT_DETAIL_ROUTE = "product_detail"

/**
 * 跳转
 */
fun NavController.navigationToProductDetail(productId: String): Unit {
    navigate("$PRODUCT_DETAIL_ROUTE/$productId")
}

/**
 * 配置导航
 */
fun NavGraphBuilder.productDetailScreen(toBack: () -> Unit): Unit {
    myComposable(
        "$PRODUCT_DETAIL_ROUTE/{$PRODUCT_ID}",
        arguments = listOf(
            // 配置传递的参数类型，默认String
            navArgument("$PRODUCT_ID") { type = NavType.StringType },
        )
    ) {
        ProductDetailRoute(toBack = toBack)
    }
}